#ifndef _EDDYTRACK_H_
#define _EDDYTRACK_H_
#include "algohub_export.h"
#include <vector>
#include <string>
#include <memory>
#include <utility>
#include "AlgoEddyDetection.h"

namespace EddyDetection {

    // Frame data structure - Each frame contains 2D eddy current detection results for multiple depths
    struct Frame {
        int frame_idx;
        std::vector<std::vector<EddyContourData>> layer_eddies; // [depth_layer][eddy_index]
        std::vector<double> depths; // Corresponding depth values
        std::string time;
    };

    // Trajectory data structure - Tracking a single 2D vortex
    struct Track {
        std::string track_id;
        std::vector<std::pair<int, EddyContourData>> eddies; // (frame_idx, EddyContourData)
        bool alive = true;
        double depth; // Depth corresponding to this trajectory
        int layer_index; // Layer index corresponding to this trajectory
        std::string time_start;
        std::string time_end;
    };

    struct EddyDynamicConfig {
        double frame_interval_hours = 24.0;  //Time step length
        double daily_match_dist_km = 50.0;  // 50km is daily math dist
        double process_noise = 1.0;  // Kalman
        double meassurement_noise = 10.0;  // Kalman
        //double merge_distance_ratio = 0.3; // merge, (split_ratio = 0.5)
        //double split_area_threshold = 2.0;
        //double merge_area_threshold = 0.5;
    };

    class ALGOHUB_EXPORT EddyDynamic {
    public:

        std::vector<Track> startDynamic(const std::vector<std::pair<std::string, VelocityData>>& velocity_datas, 
                                        const std::vector<std::pair<std::string, TemperatureData>>& temp_datas,
                                        const EddyDynamicConfig& config, 
                                        const EddyDetectionConfig& detectconfig);
    };

} // namespace EddyDetection 

#endif _EDDYTRACK_H_